﻿using System.Collections.Generic;
using Model;

namespace SoundConstructor
{
	class StopPlayingAllSoundsCommand : Command
	{
		private List<OnetimeSound> onetimeSounds;
		private List<RepeatedSound> repeatedSounds;
		private AudioPlayer audioPlayer;

		public StopPlayingAllSoundsCommand(List<OnetimeSound> onetimeSounds, List<RepeatedSound> repeatedSounds, AudioPlayer audioPlayer)
		{
			this.onetimeSounds = onetimeSounds;
			this.repeatedSounds = repeatedSounds;
			this.audioPlayer = audioPlayer;
		}

		public void Execute()
		{
			StopPlayingOnetimeSounds();
			StopPlayingRepeatedSounds();
		}

		private void StopPlayingOnetimeSounds()
		{
			foreach (OnetimeSound sound in onetimeSounds)
			{
				audioPlayer.Stop(sound.Name);
			}
		}

		private void StopPlayingRepeatedSounds()
		{
			foreach (RepeatedSound sound in repeatedSounds)
			{
				audioPlayer.Stop(sound.Name);
			}
		}
	}
}
